﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace 数据上传数据库WebAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UploadController : ControllerBase
    {
        [HttpPost]
        public ActionResult<object> UploadData(UploadDTO upload)
        {
            List<string> res = new List<string>();
            string sql = $"insert into {upload.TableName}(InsertTime,ProcessNo,SerialNo,Result) values('{upload.InsertTime}','{upload.ProcessNo}','{upload.SerialNo}','{upload.Result}')";

            try
            {
                int i = SqlHelper.Update(sql);
                res.Add($"表 -> {upload.TableName} 插入成功");
            }
            catch (Exception ex)
            {
                res.Add($"{upload.TableName} -> {ex.Message}");
            }
            return Ok(new { state = 200, msg = res });

        }
    }
}
